package com.icd.backend;

import cn.hutool.db.DbUtil;
import cn.hutool.http.HttpGlobalConfig;
import cn.hutool.log.level.Level;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.util.Collections;

@EnableFeignClients
@EnableDiscoveryClient
@EnableAsync
@Configuration
@EnableTransactionManagement
@SpringBootApplication
@MapperScan({"com.icd.backend.mapper"})
@ComponentScan({"com.inspur.icd.*", "com.inspur.idb.*", "com.icd.*"})
@ServletComponentScan(basePackages = {"com.inspur.icd.common.config.filter"})
@RequiredArgsConstructor
@Slf4j
public class IcdBackendApplication {

	public static void main(String[] args) {
		DbUtil.setShowSqlGlobal(true, false, true, Level.INFO);
		HttpGlobalConfig.setTimeout(3000);
		SpringApplication.run(IcdBackendApplication.class, args);

		String message = "启动成功";
		int borderLength = message.length() + 50;
		String border = String.join("", Collections.nCopies(borderLength, "="));
		String greenColor = "\u001B[31m";
		String resetColor = "\u001B[0m";

		System.out.println(greenColor + border + resetColor);
		System.out.println(greenColor + "                | " + message + " |                " + resetColor);
		System.out.println(greenColor + border + resetColor);
	}

}
